package adv5;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class ExpireDay {

	public static void main(String[] args) {// 3：学士后结业考试日期是每月倒数第二个周六上午，输出今年所有的考试日期

		Calendar c = Calendar.getInstance();
		for (int i = 0; i < 12; i++) {
			c.set(Calendar.MONTH, i);
			int day = c.getActualMaximum(Calendar.DAY_OF_MONTH);
			System.out.println(day);
			c.set(Calendar.DAY_OF_MONTH, day);
			int m = c.get(Calendar.DAY_OF_WEEK);
			int j = c.getActualMaximum(Calendar.WEEK_OF_MONTH);
			if (m == 7) {
				c.set(Calendar.WEEK_OF_MONTH, j - 1);
			} else {
				c.set(Calendar.WEEK_OF_MONTH, j - 2);
			}
			c.set(Calendar.DAY_OF_WEEK, 7);
			System.out.println((c.get(Calendar.MONTH) + 1) + "月的考试在" + c.get(Calendar.DAY_OF_MONTH) + "号");
		}
	}

}
